<style>
  @import "../../assets/css/index.css";
</style>
<template>
	<div class="m-content">
		<AppHeader></AppHeader>
		<div class="m-content">
			<div class="m-silder">
				<el-carousel indicator-position="outside">
				<el-carousel-item v-for="item in 4" :key="item">
				  <h3></h3>
				</el-carousel-item>
				</el-carousel>
			</div>
			<div class="warp m-news">
				<div class="m-news-top f-cb">
					<h1 class="m-news-title">系统公告</h1>
					<p class="more"><a href="###">查看更多</a></p>
				</div>
				<ul class="m-news-content">
					<li v-for="news in list">
						<a v-if="news.importance==1"  class="m-news-new"   :href="'/notice?id=' + news.id " >{{ news.title }} <span>{{ news.releasetime }}</span></a> 
						<a v-else-if="news.importance==2"  class="m-news-warning"   :href="'/notice?id=' + news.id ">{{ news.title }} <span>{{ news.releasetime }}</span></a>
						<a v-else  class=""   :href="'/notice?id=' + news.id ">{{ news.title }} <span>{{ news.releasetime }}</span></a>  
					</li>
				</ul>
			</div>
		</div>
		<Footer></Footer>
	</div>
</template>
<script>
	import AppHeader from '@/components/Header';
	import Footer from '@/components/Footer';
	export default {
		name: 'index',
		components: {
		  AppHeader,
		  Footer,
	},
	data(){
		return {
			list:[],
		}
	},
	created(){
		var that = this;
		that.axios.get('/yan-web/notice/list',{params:{'category':'1'}},{
		    headers: {
		          'Content-type': 'application/json;charset=UTF-8'
		    }
		})
		.then(function (response) {
			if(response.data.status){
				for(var i=0;i<response.data.model.rows.length;i++){
					var d = new Date(response.data.model.rows[i].releasetime);  
					response.data.model.rows[i].releasetime = that.formatDate(d) ;
				}
				that.list = response.data.model.rows
			}else{			
				that.$router.push({ path: '/index' });
				that.clearCookie();	
			}
		})		
	},
	methods: {
		formatDate:function(inputTime){
			var date = new Date(inputTime);  
		    var y = date.getFullYear();    
		    var m = date.getMonth() + 1;    
		    m = m < 10 ? ('0' + m) : m;    
		    var d = date.getDate();    
		    d = d < 10 ? ('0' + d) : d;    
		    var h = date.getHours();  
		    h = h < 10 ? ('0' + h) : h;  
		    var minute = date.getMinutes();  
		    var second = date.getSeconds();  
		    minute = minute < 10 ? ('0' + minute) : minute;    
		    second = second < 10 ? ('0' + second) : second;   
		    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;    
		}
	},

}
</script>
